//package com.xy.stock.service.impl;
//
//import com.xy.stock.service.UserService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.stereotype.Service;
//
///**springSecrity 使用数据库数据的方式:
//1，添加pom：
//<dependency>
//<groupId>org.springframework.boot</groupId>
//<artifactId>spring-boot-starter-security</artifactId>
//</dependency>
//
// 2，//加入配置项
// @Configuration
// @EnableWebSecurity
// public class ScurityConfig extends WebSecurityConfigurerAdapter {
//
// //添加密码加密方法，由于Spring Security5必须要对密码进行编码，而Spring Security4不需要
// @Bean
// public PasswordEncoder passwordEncoder(){
// return new BCryptPasswordEncoder();
// }
//
//}
//3，写下面的用户类：
//  实现springwecrity的UserDetailservice 复写方法从自己的数据库读取即可
//
// **/
//
//
//
//@Service
//public class UserServiceImpl implements UserService, UserDetailsService {
//
//    @Autowired
//    private PasswordEncoder passwordEncoder;
//
//
//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        UserDetails user = User.withUsername(username).password(passwordEncoder.encode("123456")).roles("user","admin").build();
//        return user;
//    }
//}
